﻿using System.Collections.Generic;
using MiniShellFramework;

namespace PerformanceDude.MSBuildShellExtension
{
    internal static class MSBuildRootKey
    {
        public const string ProgId = "MSBuildShellEx";
		public const string Description = "MSBuild Shell Extension";
        private static bool registered;

        public static List<string> FileExtensions = new List<string>(){".sln" , ".csproj", ".vbproj", ".vcxproj", ".vjsproj", ".vcproj", ".proj", ".targets"};

        public static void Register()
        {
            if (registered)
                return;

            foreach (string fileExtension in FileExtensions)
            {
				string existingProgId = null;
				if (!RootKey.TryGetProgIdForFileExension(fileExtension, out existingProgId))
				{
					RootKey.Register(fileExtension, ProgId);
				}
            }

            registered = true;
        }

        public static void Unregister()
        {
            if (!registered)
                return;

            foreach (string FileExtension in FileExtensions)
            {
                RootKey.Unregister(FileExtension);
            }

            registered = false;
        }
    }
}
